/**
 * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package com.bar.carta.model;

import com.bar.carta.service.TipoIdiomaLocalServiceUtil;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.model.impl.BaseModelImpl;

import java.io.Serializable;

import java.lang.reflect.Proxy;

/**
 * @author pgonzalm
 */
public class TipoIdiomaClp extends BaseModelImpl<TipoIdioma>
	implements TipoIdioma {
	public TipoIdiomaClp() {
	}

	public Class<?> getModelClass() {
		return TipoIdioma.class;
	}

	public String getModelClassName() {
		return TipoIdioma.class.getName();
	}

	public long getPrimaryKey() {
		return _tipoIdiomaId;
	}

	public void setPrimaryKey(long primaryKey) {
		setTipoIdiomaId(primaryKey);
	}

	public Serializable getPrimaryKeyObj() {
		return new Long(_tipoIdiomaId);
	}

	public void setPrimaryKeyObj(Serializable primaryKeyObj) {
		setPrimaryKey(((Long)primaryKeyObj).longValue());
	}

	public long getTipoIdiomaId() {
		return _tipoIdiomaId;
	}

	public void setTipoIdiomaId(long tipoIdiomaId) {
		_tipoIdiomaId = tipoIdiomaId;
	}

	public long getTipoId() {
		return _tipoId;
	}

	public void setTipoId(long tipoId) {
		_tipoId = tipoId;
	}

	public String getName() {
		return _name;
	}

	public void setName(String name) {
		_name = name;
	}

	public String getDescripcion() {
		return _descripcion;
	}

	public void setDescripcion(String descripcion) {
		_descripcion = descripcion;
	}

	public int getIdioma() {
		return _idioma;
	}

	public void setIdioma(int idioma) {
		_idioma = idioma;
	}

	public void persist() throws SystemException {
		if (this.isNew()) {
			TipoIdiomaLocalServiceUtil.addTipoIdioma(this);
		}
		else {
			TipoIdiomaLocalServiceUtil.updateTipoIdioma(this);
		}
	}

	@Override
	public TipoIdioma toEscapedModel() {
		return (TipoIdioma)Proxy.newProxyInstance(TipoIdioma.class.getClassLoader(),
			new Class[] { TipoIdioma.class }, new AutoEscapeBeanHandler(this));
	}

	@Override
	public Object clone() {
		TipoIdiomaClp clone = new TipoIdiomaClp();

		clone.setTipoIdiomaId(getTipoIdiomaId());
		clone.setTipoId(getTipoId());
		clone.setName(getName());
		clone.setDescripcion(getDescripcion());
		clone.setIdioma(getIdioma());

		return clone;
	}

	public int compareTo(TipoIdioma tipoIdioma) {
		long primaryKey = tipoIdioma.getPrimaryKey();

		if (getPrimaryKey() < primaryKey) {
			return -1;
		}
		else if (getPrimaryKey() > primaryKey) {
			return 1;
		}
		else {
			return 0;
		}
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}

		TipoIdiomaClp tipoIdioma = null;

		try {
			tipoIdioma = (TipoIdiomaClp)obj;
		}
		catch (ClassCastException cce) {
			return false;
		}

		long primaryKey = tipoIdioma.getPrimaryKey();

		if (getPrimaryKey() == primaryKey) {
			return true;
		}
		else {
			return false;
		}
	}

	@Override
	public int hashCode() {
		return (int)getPrimaryKey();
	}

	@Override
	public String toString() {
		StringBundler sb = new StringBundler(11);

		sb.append("{tipoIdiomaId=");
		sb.append(getTipoIdiomaId());
		sb.append(", tipoId=");
		sb.append(getTipoId());
		sb.append(", name=");
		sb.append(getName());
		sb.append(", descripcion=");
		sb.append(getDescripcion());
		sb.append(", idioma=");
		sb.append(getIdioma());
		sb.append("}");

		return sb.toString();
	}

	public String toXmlString() {
		StringBundler sb = new StringBundler(19);

		sb.append("<model><model-name>");
		sb.append("com.bar.carta.model.TipoIdioma");
		sb.append("</model-name>");

		sb.append(
			"<column><column-name>tipoIdiomaId</column-name><column-value><![CDATA[");
		sb.append(getTipoIdiomaId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>tipoId</column-name><column-value><![CDATA[");
		sb.append(getTipoId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>name</column-name><column-value><![CDATA[");
		sb.append(getName());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>descripcion</column-name><column-value><![CDATA[");
		sb.append(getDescripcion());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>idioma</column-name><column-value><![CDATA[");
		sb.append(getIdioma());
		sb.append("]]></column-value></column>");

		sb.append("</model>");

		return sb.toString();
	}

	private long _tipoIdiomaId;
	private long _tipoId;
	private String _name;
	private String _descripcion;
	private int _idioma;
}